package com.cxcs.cxcsojbackendquestionservice.controller.inner;


import com.cxcs.cxcsojbackendmodel.entity.Question;
import com.cxcs.cxcsojbackendmodel.entity.QuestionSubmit;
import com.cxcs.cxcsojbackendquestionservice.service.QuestionService;
import com.cxcs.cxcsojbackendquestionservice.service.QuestionSubmitService;
import com.cxcs.cxcsojbackendserviceclient.service.QuestionFeignClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 【远程接口实现类】 题目服务
 *      该服务仅供内部调用
 *
 * @Author: CxCS
 * @Version: 1.0
 * @Date: 2024-08
 */
@RestController
@RequestMapping("/inner")
public class QuestionInnerController implements QuestionFeignClient {

    @Resource
    private QuestionService questionService;
    @Resource
    private QuestionSubmitService questionSubmitService;

    @GetMapping("/get/id")
    public Question getQuestionById(@RequestParam("questionId") long questionId) {
        return questionService.getById(questionId);
    }

    @PostMapping("/update")
    public Boolean updateQuestionById(@RequestBody Question question) {
        return questionService.updateById(question);
    }

    @GetMapping("/question_submit/get/id")
    public QuestionSubmit getQuestionSubmitById(@RequestParam("questionSubmitId") long questionSubmitId) {
        return questionSubmitService.getById(questionSubmitId);
    }

    @PostMapping("/question_submit/update")
    public Boolean updateQuestionSubmitById(@RequestBody QuestionSubmit questionSubmit) {
        return questionSubmitService.updateById(questionSubmit);
    }
}
